package 力扣日常刷题.木23四月.第2天402;

import 力扣日常刷题.TreeNode;

/*
* 节点变成  >= 节点的和
* */

public class Demo12把二叉树转化成累加树 {


    int sum = 0;
    public TreeNode convertBST(TreeNode root) {
        if(root != null){
            convertBST(root.right);
            sum += root.val;
            root.val = sum;
            convertBST(root.left);
        }
        return root;
    }
}
